package com.gzx.asr.utils;

public class FileUtils {
    //截取音频全路径不保留后缀
    public static String removeWavExtension(String path) {
        if (path == null || !path.toLowerCase().endsWith(".wav")) {
            return path;  // 非.wav文件保持原样
        }
        return path.substring(0, path.length() - 4);
    }

    //左声道
    public static String splitLeftChannel(String path) {
        if (path == null || !path.toLowerCase().endsWith(".wav")) {
            return path;  // 非.wav文件保持原样
        }
        return path.substring(0, path.length() - 4) + "_left_channel.wav";
    }

    //右声道
    public static String splitRightChannel(String path) {
        if (path == null || !path.toLowerCase().endsWith(".wav")) {
            return path;  // 非.wav文件保持原样
        }
        return path.substring(0, path.length() - 4) + "_right_channel.wav";
    }

    //把左声道替换成右声道
    public static String replaceRightChannel(String path) {
        if (path == null || !path.toLowerCase().endsWith(".wav")) {
            return path;  // 非.wav文件保持原样
        }
        return path.replace("left", "right");
    }

}
